//
//  BGAdversitingCell.m
//  bigMall
//
//  Created by ios on 16/9/29.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGAdversitingCell.h"

@implementation BGAdversitingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)layoutSubviews {
    
    for (UIView *v in self.contentView.subviews) {
        [v removeFromSuperview];
    }
    
    //修饰条
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 7)];
    v.backgroundColor = dockwhite_;
    [self.contentView addSubview:v];
    
    //name
    UILabel *nameLab = [[UILabel alloc] initWithFrame:CGRectMake(21, v.bottom + 10, ([UIScreen mainScreen].bounds.size.width - 42) / 2, 21)];
    nameLab.text = self.nameStr;
    nameLab.font = [UIFont systemFontOfSize:16];
//    CGSize nameSize = [nameLab.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:nameLab.font,NSFontAttributeName, nil]];
    nameLab.frame = CGRectMake(21, v.bottom + 10, ([UIScreen mainScreen].bounds.size.width - 42) / 2, 21);
    [self.contentView addSubview:nameLab];
    
    //time
    UILabel *timeLab = [[UILabel alloc] init];
    NSDateFormatter *fat = [[NSDateFormatter alloc] init];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[self.timeStr intValue]];
    [fat setDateFormat:@"yyyy-MM-dd "];
    NSString *str = [fat stringFromDate:date];
    timeLab.text = [NSString stringWithFormat:@"时间：%@",str];
    timeLab.font = [UIFont systemFontOfSize:16];
    CGSize timeSize = [timeLab.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:timeLab.font,NSFontAttributeName, nil]];
    timeLab.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 21 - timeSize.width, nameLab.y, timeSize.width, 21);
    [self.contentView addSubview:timeLab];
    
    //cont
    UILabel *contLab = [[UILabel alloc] initWithFrame:CGRectMake(21, timeLab.bottom + 10, [UIScreen mainScreen].bounds.size.width - 42, 43)];
    contLab.numberOfLines = 0;
    contLab.lineBreakMode = NSLineBreakByCharWrapping;
    contLab.text = [NSString stringWithFormat:@"内容：%@",self.contStr];
    contLab.font = [UIFont systemFontOfSize:16];
//    CGSize contSize = [contLab.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:contLab.font,NSFontAttributeName, nil]];
//    contLab.bounds = CGRectMake(0, 0, contSize.width, 21);
//    [self.contentView addSubview:contLab];
    
    //autor
    UILabel *autorLab = [[UILabel alloc] initWithFrame:CGRectMake(21, contLab.bottom + 10,100, 21)];
    autorLab.font = [UIFont systemFontOfSize:16];
    autorLab.text = [NSString stringWithFormat:@"作者：%@",self.authorStr];
//    [self.contentView addSubview:autorLab];
    
    //count
    UILabel *countLab = [[UILabel alloc] initWithFrame:CGRectMake(21, timeLab.bottom + 10,100, 21)];
    countLab.text = [NSString stringWithFormat:@"浏览：%@",self.countStr];
    countLab.font = [UIFont systemFontOfSize:16];
//    CGSize countSize = [countLab.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:countLab.font,NSFontAttributeName,nil]];
//    countLab.frame = CGRectMake(timeLab.x, autorLab.y, countSize.width, 21);
    [self.contentView addSubview:countLab];
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
